<?php

namespace app\controller\api;

use plugin\admin\app\model\User;
use support\Db;
use support\Redis;
use support\Request;
use support\Response;
use Tinywan\Jwt\JwtToken;

class UserController extends BaseController
{
    public function getUserInfo(): Response
    {
        $list = User::where(['status'=>0])->first();
        return Response::success($list);
    }
    /**
     * 访问日志
     */
    public function addAccessLog(Request $request): Response
    {
        $data = $request->post();
        // 或者使用这种方式
        $clientIP = $request->server['remote_addr'];
        $data['ip'] = $clientIP;
        Redis::lpush('user_logs_queue', json_encode($data));
        /*while (true) {
            $logData = Redis::brpop('user_logs_queue', 0)[1]; // 从队列中获取日志数据
            // 将日志数据存储到 MySQL 表

        }*/
        return Response::success($data);
    }
}